package com.micro.common.exception;

/**
 * @author pan.shun
 * @since 2022/7/5 16:42
 */
public class NotAuthException extends RuntimeException {
    private int code = 403;

    public NotAuthException(String msg) {
        super(msg);
    }

    public NotAuthException(String msg, Throwable e) {
        super(msg, e);
    }

    public NotAuthException(String msg, int code) {
        super(msg);
        this.setCode(code);
    }

    public NotAuthException(String msg, int code, Throwable e) {
        super(msg, e);
        this.setCode(code);
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof GlobalException)) {
            return false;
        } else {
            GlobalException other = (GlobalException) o;
            if (!other.canEqual(this)) {
                return false;
            } else {
                return this.getCode() == other.getCode();
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof GlobalException;
    }


    public String toString() {
        return "NotAuthException(code=" + this.getCode() + ")";
    }
}
